home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 February
/
Ahoy_Magazine_87-02_1987_Double_L.d64
/
Six Couples
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
626b
|
23 lines
0 rem << cd38-6 >>
1 rem commodares problem #34-4:
2 print" six couples"
3 rem solution by
4 rem bill hoyt
5 rem
10 dim sp$(2,12),t(12)
20 data a,ts,b,,c,ys,d,td,e,t,f,yt,p,yds,q,ytd,r,,s,ds,t,yd,u,s
30 a$="ytds"
40 for n=1 to 12 : read sp$(1,n),sp$(2,n) : next n
50 for n=1 to 4 : ct=ct+asc(mid$(a$,n,1)) : next
60 for x=1 to 12 : vx=0
70 lx=len(sp$(2,x)) : if lx=0 then 90
80 for n=1 to lx : vx=vx+asc(mid$(sp$(2,x),n,1)) : next n
90 t(x)=vx : next x
100 for x=1 to 11 : for y=x+1 to 12
110 if t(x)+t(y)<>ct then 140
120 print sp$(1,x)" & "sp$(1,y)
130 sp$(0,x)="*" : sp$(0,y)="*"
140 next y : next x
150 for n=1 to 12 : if sp$(0,n)<>"*" then print sp$(1,n)" unmatched "sp$(2,n)
160 next n